<template>
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>

    <div style="margin-left: 10px;">
      <el-form ref="form" :rules="rules" label-width="120px">
        <el-table :data="columns" ref="dragTable" row-key="id" v-loading="loading">
          <el-table-column label="排序" align="center" prop="idx"  />
          <el-table-column label="工序编号" align="center" prop="code"  />
          <el-table-column label="工序名称" align="center" prop="name"  />
          <el-table-column label="计件工资" align="center" prop="money"  />
          <el-table-column label="产品编码" align="center" prop="goodsCode"/>
          <el-table-column label="产品名称" align="center" prop="goodsName"/>
          <el-table-column label="产品型号" align="center" prop="goodsModel"/>
          <el-table-column label="关联设备" align="center" prop="photo"  />
          <el-table-column label="使用车间id" align="center" prop="deptId"/>
          <el-table-column label="使用车间" align="center" prop="deptName"/>
          <el-table-column label="标准工时" align="center" prop="workHour"/>
          <el-table-column label="图纸号" align="center" prop="shuoming" show-overflow-tooltip />
          <el-table-column align="center" label="工序文件" prop="file" width="200">
            <template slot-scope="scope">
              <image-preview v-if="scope.row.file" :src="scope.row.file" height="60px" width="40px"></image-preview>
            </template>
          </el-table-column>
          <!--<el-table-column align="center" label="工序图纸" prop="photo" width="200">
                <template slot-scope="scope">
                  <image-preview :src="scope.row.photo" height="60px" width="40px"></image-preview>
                </template>
              </el-table-column>-->
          <!--<el-table-column label="备注" align="center" prop="remark"/>-->
        </el-table>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {
    getAction,
    addAction,
    getById
  } from '@/api/manage'

  export default {
    name: "ShowGongxuList",
    components: {},
    data() {
      return {
        title: "工序1列表",
        open: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        rows: [],
        rules: {},
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 销售信息管理表格数据
        dataList: [],
        columns: [],
        gongyiId: null,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 20000,
          gongyiId: null,
          gongxuId: null,
          code: null,
          name: null,
          //orderByColumn: "idx+0",
          //isAsc: "asc",
          params: {},
        },
        url: {
          list: '/lnGongyigongxu/lnGongyigongxu/list',
        },
        tableMaxHeight: window.innerHeight - 320,
      };
    },
    created() {
      // this.intDictsForPrj();
      window.addEventListener('resize', this.getTableHeight);
    },
    destroyed() {
      window.removeEventListener('resize', this.getTableHeight);
    },
    methods: {
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      getTableHeight() {
        this.tableHeight = window.innerHeight - 320
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      showGx(gongyiId) {
        this.queryParams.gongyiId = gongyiId;
        this.open = true;
        this.getList();
      },
      /** 查询销售信息管理列表 */
      getList() {
        this.loading = true;
        getAction(this.url.list, this.queryParams).then(response => {
          this.columns = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
    }
  };
</script>
